Skip to content

refactor: split browser and auth-proxy ingresses. - #586

Open
pantierra wants to merge 2 commits into
mainfrom
fix/unified-ingress-routing
Open

refactor: split browser and auth-proxy ingresses.#586
pantierra wants to merge 2 commits into
mainfrom
fix/unified-ingress-routing

Conversation

@pantierra

@pantierra pantierra commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Closes #568.

@claude

claude Bot commented Jul 23, 2026

Copy link
Copy Markdown

Claude finished @pantierra's task in 3m 8s —— View job


Claude's Review

  • Fetch and review full diff (origin/main...HEAD)
  • Review templates/_helpers/networking.tpl changes
  • Review new ingress templates (auth-proxy, browser) and modified ingress.yaml/traefik-middleware.yaml
  • Review test files for correctness
  • Apply ponytail-review for over-engineering findings
  • Post final review

✅ No blocking issues — safe to merge.

Both previously-requested changes are addressed:

  • The notContains assertions across ingress_test.yaml, stac-auth-proxy-ingress_test.yaml, and stac_browser_tests.yaml now all carry any: true, so they actually fail when the path is present (verified none were missed).
  • eoapi.ingressCommonAnnotations (charts/eoapi/templates/_helpers/networking.tpl:83) now merges a user-supplied traefik.ingress.kubernetes.io/router.middlewares with the chart-owned value (user,owned) instead of silently overwriting it, and this is covered by the updated test in ingress_test.yaml:446 ("chart middlewares merge with user router.middlewares annotation").

Traced the refactor end-to-end (eoapi.ingressFlags, eoapi.ingressManifest, the three ingress templates, and the Traefik middleware) against the test suite:

  • Browser is fully split out of eoapi.enabledIngressServices onto its own rewrite-free ingress; no dangling references to the removed eoapi.hasEnabledService/eoapi.traefikStripPrefixes helpers remain.
  • NGINX auth-proxy passthrough (auth-proxy-ingress.yaml, gated by passthroughIngress) vs. Traefik keeping auth-proxy on the main ingress (and correctly omitting /stac from strip-prefix, since stripPath is false when useAuthProxy is true) both check out against their respective tests.
  • The omit mechanism in eoapi.ingressManifest correctly strips nginx rewrite-target/use-regex annotations from the browser/auth-proxy variants even if a user supplies them globally via ingress.annotations, matching the "strips nginx rewrite annotations from the browser ingress" test.
  • No nil-map risk from the new $entry.config | default (index $root.Values $entry.key) pattern for mockOidcServertesting.mockOidcServer exists in values.yaml and all sub-key access goes through | default dict.

Note: I wasn't able to execute helm unittest/ct lint in this sandbox (no shell execution permission beyond read-only git), so this is a static review only — the described test updates look internally consistent with the template logic, but a green CI run should still be the final confirmation.

Simplify (ponytail)

  • charts/eoapi/templates/_helpers/networking.tpl:120 (eoapi.ingressCommonAnnotations) — the omit param is generic (arbitrary key list) but only ever called with one hardcoded list (nginxRewriteKeys) from eoapi.ingressManifest; could inline two unset calls in ingressManifest after the include instead of threading a generic list through both templates. Minor, not worth blocking on.

💰 Estimated review cost: $0.73 · 3m08s · 32 turns

@pantierra
pantierra force-pushed the fix/unified-ingress-routing branch 2 times, most recently from b2068f8 to 652a443 Compare July 24, 2026 00:07
@pantierra
pantierra force-pushed the fix/unified-ingress-routing branch 3 times, most recently from 0c5165d to c4bb6ea Compare July 24, 2026 00:34
@pantierra
pantierra requested a review from lhoupert July 24, 2026 00:41
@pantierra
pantierra marked this pull request as ready for review July 24, 2026 00:41
@pantierra
pantierra force-pushed the fix/unified-ingress-routing branch 2 times, most recently from 364dceb to 81e90d4 Compare July 24, 2026 00:46
Comment on lines +49 to +55
- notContains:
path: spec.rules[0].http.paths
content:
path: /stac
- equal:
path: metadata.annotations["nginx.ingress.kubernetes.io/rewrite-target"]
value: /$2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that these notContains assertions can never fail without any: true
The assertion seems to pass even when the path is present, and fails correctly once any: true is added.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment on lines +140 to +147
- notContains:
path: spec.rules[0].http.paths
content:
pathType: Prefix
path: /stac
backend:
service:
name: RELEASE-NAME-stac-auth-proxy
port:
number: 8080
- contains:
- notContains:
path: spec.rules[0].http.paths
content:
pathType: ImplementationSpecific
path: /browser(/|$)(.*)
backend:
service:
name: RELEASE-NAME-browser
port:
number: 8080
path: /browser

@lhoupert lhoupert Jul 29, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SAme issue as above

Comment on lines +140 to +147
- notContains:
path: spec.rules[0].http.paths
content:
pathType: Prefix
path: /stac
backend:
service:
name: RELEASE-NAME-stac-auth-proxy
port:
number: 8080
- contains:
- notContains:
path: spec.rules[0].http.paths
content:
pathType: ImplementationSpecific
path: /browser(/|$)(.*)
backend:
service:
name: RELEASE-NAME-browser
port:
number: 8080
path: /browser

@lhoupert lhoupert Jul 29, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- notContains:
path: spec.rules[0].http.paths
content:
pathType: Prefix
path: /stac
backend:
service:
name: RELEASE-NAME-stac-auth-proxy
port:
number: 8080
- contains:
- notContains:
path: spec.rules[0].http.paths
content:
pathType: ImplementationSpecific
path: /browser(/|$)(.*)
backend:
service:
name: RELEASE-NAME-browser
port:
number: 8080
path: /browser
- notContains:
path: spec.rules[0].http.paths
content:
path: /stac
any: true
- notContains:
path: spec.rules[0].http.paths
content:
path: /browser
any: true
- notContains:
path: spec.rules[0].http.paths
content:
path: /browser(/|$)(.*)
any: true

Comment on lines +229 to +232
- notContains:
path: spec.rules[0].http.paths
content:
path: "/browser"

@lhoupert lhoupert Jul 29, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sane issue than https://github.com/developmentseed/eoapi-k8s/pull/586/changes#r3675257745

Suggested change
- notContains:
path: spec.rules[0].http.paths
content:
path: "/browser"
- notContains:
path: spec.rules[0].http.paths
content:
path: "/browser"
any: true
- notContains:
path: spec.rules[0].http.paths
content:
path: "/browser(/|$)(.*)"
any: true

Comment on lines +49 to +52
- notContains:
path: spec.rules[0].http.paths
content:
path: /stac

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- notContains:
path: spec.rules[0].http.paths
content:
path: /stac
- notContains:
path: spec.rules[0].http.paths
content:
path: /stac
any: true
- notContains:
path: spec.rules[0].http.paths
content:
path: /stac(/|$)(.*)
any: true

{{- $_ := set $annotations "traefik.ingress.kubernetes.io/router.entrypoints" ($root.Values.ingress.entrypoints | toString) -}}
{{- end -}}
{{- $annotations = mergeOverwrite $annotations ($root.Values.ingress.annotations | default dict) -}}
{{- $annotations = mergeOverwrite $annotations $owned -}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While testing this branch with Claude it noticed that a user supplied traefik.ingress.kubernetes.io/router.middlewares in ingress.annotations can get silently dropped

To reproduce:

 helm template eoapi charts/eoapi \
   --set ingress.className=traefik \
   --set browser.enabled=true --set raster.enabled=true \
   --set 'ingress.annotations.traefik\.ingress\.kubernetes\.io/router\.middlewares=default-forward-auth@kubernetescrd'
Ingress router.middlewares value rendered
eoapi-browser-ingress default-eoapi-browser-redirect-middleware@kubernetescrd
eoapi-ingress (main) default-eoapi-strip-prefix-middleware@kubernetescrd

default-forward-auth@kubernetescrd, the value set isn't in either one. It's not appended or merged, just replaced, with no warning 😬

Would it make sense to append instead of overwrite? e.g. in eoapi.ingressCommonAnnotations, just before the final merge:

 {{- $mwKey := "traefik.ingress.kubernetes.io/router.middlewares" -}}
 {{- if and (hasKey $annotations $mwKey) (hasKey $owned $mwKey) -}}
 {{- $_ := set $owned $mwKey (printf "%s,%s" (get $annotations $mwKey) (get $owned $mwKey)) -}}
 {{- end -}}

With that change, the same command renders:

Ingress router.middlewares value rendered
eoapi-browser-ingress default-forward-auth@kubernetescrd,default-eoapi-browser-redirect-middleware@kubernetescrd
eoapi-ingress (main) default-forward-auth@kubernetescrd,defauleware@kubernetescrd

what do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed.

@pantierra
pantierra force-pushed the fix/unified-ingress-routing branch 2 times, most recently from 52bb6b6 to a7e5d7d Compare August 25, 2026 11:11
@pantierra
pantierra requested a review from lhoupert August 25, 2026 11:18
@pantierra
pantierra force-pushed the fix/unified-ingress-routing branch from a7e5d7d to 7fc2658 Compare August 25, 2026 11:20
@pantierra

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @lhoupert! I addressed the mentioned issues and cleaned up a bit more. I'd appreciate another round of review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants